package com.yuanyi.api.comm.msg;

import lombok.Data;

import java.util.List;

@Data
public class TableResultResponse<T> extends BaseResponse {

    protected TableData<T> data;

    public TableResultResponse(long total, List<T> rows) {
        this.data = new TableData<T>(total, rows);
    }

    public TableResultResponse(){this.data = new TableData<T>();}

    protected TableResultResponse<T> total(int total) {
        this.data.setTotal(total);
        return this;
    }

    class TableData<T> {
        private long total;

        private List<T> rows;

        public TableData(long total, List<T> rows) {
            this.total = total;
            this.rows = rows;
        }

        public TableData(){}

        public long getTotal() {
            return total;
        }

        public void setTotal(long total) {
            this.total = total;
        }

        public List<T> getRows() {
            return rows;
        }

        public void setRows(List<T> rows) {
            this.rows = rows;
        }
    }

}
